/*
 * util.c
 *
 *  Created on: 01.12.2012
 *      Author: jbolay
 */

#include "util.h"

void convertByteToHex(char* str, uint8_t byte){
	char loockup[] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46};
	str[0] = ' ';
	str[1] = '0';
	str[2] = 'x';
	str[3] = loockup[((byte & 0b11110000) >> 4)];
	str[4] = loockup[(byte & 0b00001111)];
	str[5] = '\0';
}

void convertWordToHex(char* str, uint16_t byte){
	char loockup[] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46};
		str[0] = ' ';
		str[1] = '0';
		str[2] = 'x';
		str[3] = loockup[((byte & 0xF000) >> 12)];
		str[4] = loockup[((byte & 0x0F00) >> 8)];
		str[5] = loockup[((byte & 0x00F0) >> 4)];
		str[6] = loockup[((byte & 0x000F) >> 0)];
		str[7] = '\0';
}
